#include <cstdio>
const int N = 5005;
int n, q;
int a[N];
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("binary.in", "r", stdin);
	freopen("binary.out", "w", stdout);
#endif
#endif

	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); }
	int x, y;
	long long opt;
	while (q--) {
		scanf("%lld%d%d", &opt, &x, &y);
		if (opt == 1) {
			a[x] = y;
		} else {
			opt = 0;
			for (int i = 1; i <= n; ++i) { opt += (a[i] + x) & y; }
			printf("%lld\n", opt);
		}
	}
	return 0;
}